import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
// 引入移动端rem适配插件
import 'amfe-flexible'
// 引入路由守卫
import '@/utils/permission.js'
// 测试
import { allChannelListAPI } from '@/api'
// import { Search, NavBar, Form, Field, Button, Tabbar, TabbarItem, Icon, Tab, Tabs, Cell, CellGroup, List, PullRefresh, ActionSheet, Popup, Row, Col, Badge, Divider, Tag, Image as VanImage, Dialog, DatetimePicker, Loading, Lazyload } from 'vant'

import Directive from '@/utils/directive'
import hljs from 'highlight.js' // hljs对象
import 'highlight.js/styles/default.css'
import './VantRegister'
Vue.directive('highlight', function (el) { // 自定义一个代码高亮指令
  const highlight = el.querySelectorAll('pre, code') // 获取里面所有pre或者code标签
  highlight.forEach((block) => {
    hljs.highlightElement(block) // 突出显示这些标签(以及内部代码, 会自动识别语言)
  })
})
Vue.use(Directive)
// Vue.use(Lazyload)
// Vue.use(Loading)
// Vue.use(DatetimePicker)
// Vue.use(Dialog)
// Vue.use(VanImage)
// Vue.use(CellGroup)
// Vue.use(Tag)
// Vue.use(Divider)
// Vue.use(Search)
// Vue.use(Badge)
// Vue.use(Row)
// Vue.use(Col)
// Vue.use(Popup)
// Vue.use(ActionSheet)
// Vue.use(PullRefresh)
// Vue.use(List)
// Vue.use(Cell)
// Vue.use(CellGroup)
// Vue.use(Tab)
// Vue.use(Tabs)
// Vue.use(Icon)
// Vue.use(Tabbar)
// Vue.use(TabbarItem)
// Vue.use(Button)
// Vue.use(Form)
// Vue.use(Field)
// Vue.use(NavBar) // 代码高亮的样式

// 把生产环境中的控制台打印清空掉
if (process.env.NODE_ENV !== 'development') {
  console.log = function () {}
  console.error = function () {}
  console.dir = function () {}
}
const getFn = async () => {
  try {
    await allChannelListAPI()
  } catch (error) {
    if (error.request.status === 404) {
      return console.log('网址输入错误了┗|｀O′|┛ 嗷~~', error.message)
    }

    return alert('请求失败，请稍后重试┗|｀O′|┛ 嗷~~')
  }
}
getFn()

Vue.config.productionTip = false
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
